package com.tanhua.controller;

import com.tanhua.dto.RecommendUserDto;
import com.tanhua.exception.BusinessException;
import com.tanhua.server.TanhuaService;
import com.tanhua.vo.PageResult;
import com.tanhua.vo.TodayBest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {
    @Autowired
    private TanhuaService tanhuaService;
    /*
    *
    * 查询今日佳人
    * */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        TodayBest vo =tanhuaService.todayBest();
        return  ResponseEntity.ok(vo);
    }
    /*
    *分页查询推荐好友列表
    * */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserDto dto) {
        PageResult pr = tanhuaService.recommendation(dto);
        return ResponseEntity.ok(pr);
    }
    /*
    * 查看今日佳人详情
    * */
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id") Long userId) {
        TodayBest best = tanhuaService.personalInfo(userId);
        return ResponseEntity.ok(best);
    }
    /*
     * 查询陌生人问题
     * */
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
       String question = tanhuaService.strangerQuestions(userId);
        return  ResponseEntity.ok(question);
    }
    /*
    * 回复陌生人问题
    * */
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyQuestions(@RequestBody Map map) throws BusinessException {
        String Id = map.get("userId").toString();
        Long userId = Long.valueOf(Id);
        String reply = map.get("reply").toString();
        tanhuaService.replyQuestions(userId,reply);
        return ResponseEntity.ok(null);
    }
}
